<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title> 小程序管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black"> 
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">
  
  <link rel="stylesheet" href="/Public/layui/css/layui.css"  media="all">
  <style type="text/css">
  .layui-table{
    text-align: center;
  }
  .layui-table td, .layui-table th{
    text-align: center;
  }
  </style>
</head>
<body>
<div class="layui-layout layui-layout-admin">

  <!--菜单列表-->
  <div id = "divhead"></div>
  <div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding:0 15px;">
      <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>字典管理</legend>
      </fieldset>
      <table class="layui-table">
        <colgroup>
          <col width="100">
          <button class="add-book layui-btn layui-btn-small">添加</button>
        </colgroup>
        <thead>
          <tr>
            <th>ID</th>
            <th>类型</th>
            <th>数据key值</th>
            <th>数据value值</th>
            <th>父类id</th>
            <th>子类id</th>
            <th>添加时间</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          <?php if(is_array($res["list"])): foreach($res["list"] as $key=>$vo): ?><tr>
            <td><?php echo ($vo["id"]); ?></td>
            <td><?php echo ($vo["type"]); ?></td>
            <td><?php echo ($vo["name"]); ?></td>
            <td><?php echo ($vo["value"]); ?></td>
            <td><?php echo ($vo["pid"]); ?></td>
            <td><?php echo ($vo["cid"]); ?></td>
            <td><?php echo ($vo["time"]); ?></td>
            <td>
              <button data-id="<?php echo ($vo["id"]); ?>" class="edit-book layui-btn layui-btn-small">编辑</button>
              <button class="layui-btn layui-btn-small">删除</button>
            </td>
          </tr><?php endforeach; endif; ?>
        </tbody>
      </table>
      <input id = "count" hidden value = "<?php echo ($res['count']); ?>"/>
      <div id="page-box"></div>
    </div>
  </div>
  
  <div class="layui-footer">
    <!-- 底部固定区域 -->
  </div>
</div>
<script src="/Public/layui/layui.js" charset="utf-8"></script>
<script src="/Public/js/jquery-1.11.1.min.js" charset="utf-8"></script>
<script>
  $(function(){
      $('#divhead').load('/index.php/Tongcheng/Index/menu/wid/2.html');
  })
//JavaScript代码区域
layui.use(['element','laypage','layer'], function(){
  var element = layui.element
          ,$ = layui.jquery
          ,layer = layui.layer
          ,laypage = layui.laypage;
  var count = $("#count").val();

  laypage.render({
    elem: 'page-box'
    ,count: count
    ,layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
    ,jump: function(obj){
      console.log(obj)
    }
  });
  $(".edit-book").on('click', function(event) {
      var id = $(this).data('id');
      layer.open({
          type: 2,
          title: '编辑商品',
          shadeClose: true,
          shade: false,
          maxmin: true, //开启最大化最小化按钮
          area: ['1000px', '700px'],
          content: '<?php echo U("edit");?>?id='+ id
      });
  });
    $(".add-book").on('click', function(event) {
        layer.open({
            type: 2,
            title: '编辑商品',
            shadeClose: true,
            shade: false,
            maxmin: true, //开启最大化最小化按钮
            area: ['1000px', '700px'],
            content: '<?php echo U("add");?>'
        });
    });
});
</script>
</body>
</html>